﻿<UserControl
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2006"
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  xmlns:witty="clr-namespace:Witty"
  mc:Ignorable="d"
  x:Class="Witty.LoginControl"
  x:Name="UserControl"
  Width="225" Height="270" 
  Loaded="UserControl_Loaded">
    <UserControl.CommandBindings>
        <CommandBinding Command="{x:Static witty:LoginControl.RequestPin}" Executed="RequestPin_Executed" />
        <CommandBinding Command="{x:Static witty:LoginControl.SupplyPin}" Executed="SupplyPin_Executed" />
    </UserControl.CommandBindings>

        <Border x:Name="LayoutRoot" CornerRadius="5,5,5,5" BorderBrush="{DynamicResource PrimaryBorderBrush}" BorderThickness="1,0,1,1" Background="{DynamicResource LoginBackgroundBrush}">
    <StackPanel Margin="15" VerticalAlignment="Center">
                <TextBlock TextWrapping="Wrap">Click the button below to launch your web browser and sign in, then enter the PIN supplied by Twitter below.</TextBlock>

                <Button 
                        x:Name="LoginButton"
                        Command="{x:Static witty:LoginControl.RequestPin}" 
                        Content="_Request PIN"
                        Margin="8"
                        Padding="8,0"
                        HorizontalAlignment="Center" 
                        VerticalAlignment="Center" 
                        Width="Auto" />

                <Label 
                        x:Name="pinLabel"
                        Target="{Binding ElementName=pinEdit}"
                        Content="_PIN" />
                <TextBox 
                        x:Name="pinEdit"
                        Text="{Binding Pin,UpdateSourceTrigger=PropertyChanged}"
                        />

            <Button 
                        x:Name="SupplyPinButton"
                        Command="{x:Static witty:LoginControl.SupplyPin}" 
                        Content="_Supply PIN"
                        Margin="8"
                        Padding="8,0"
                        HorizontalAlignment="Center" 
                        VerticalAlignment="Center" 
                        Width="Auto" />
        </StackPanel>
  </Border>
</UserControl>